<template>
  <el-dialog
    :close-on-click-modal="false"
    :before-close="handleClose()"
    :visible.sync="flag"
    title="访问地址"
    width="300px"
  >
    <el-form>
      <el-form-item
        v-for="item in clusterList"
        :key="item.cmFlag"
        :value="item.cmFlag"
        label-width="160"
      >
        <el-link
          type="primary"
          target="_blank"
          @click="openUrl(item)"
        >
          {{ item.cmName }}
        </el-link>
      </el-form-item>
    </el-form>
    <div
      slot="footer"
      class="dialog-footer"
    >
      <el-button
        type="primary"
        @click="flag = false"
      >关闭
      </el-button>
    </div>
  </el-dialog>
</template>
<script>
import monitor from '@/api/monitor/monitor'

export default {
  data() {
    return {
      clusterList: [],
      flag: false,
      centerId: ''
    }
  },
  created() {
    this.centerId = sessionStorage.getItem('sysKernelId')
    this.selClusterInfos()
  },
  methods: {
    openUrl(data) {
      window.open(data.url)
    },
    selClusterInfos() {
      const reqData = { 'centerId': this.centerId }
      monitor.selAllCm(reqData).then(res => {
        this.clusterList = res
      })
    },
    handleClose() {
    }
  }
}
</script>
